$('.datatable-basic').DataTable({
	 "ajax" : {
		"url" : contextpath + "customer/list",
		"data" : function(d) {
            var query = $("#query").serializeObject();
            query["size"] = d.length;
            query["page"] = (d.start/d.length);
			return query;
		},
		"dataFilter": function(data){
            var json = jQuery.parseJSON( data );
            json.recordsTotal = json.totalElements;
            json.recordsFiltered = json.totalElements;
            json.data = json.content;
 
            return JSON.stringify( json );
        }
	 },
	 "columns": [
         { "data": "name" },
         { "data": "phoneNo" },
         { "data": "birthday" },
         {
        	 render : function(data, type, row, meta) {
        		 var province = row.province == null ? '' : row.province;
           		 var city = row.city == null ? '' : row.city;
           		 var area = row.area == null ? '' : row.area;
           		 var address = row.address == null ? '' : row.address;
           		 return province + city + area + address;
        	 }
         }
     ],
     "drawCallback": function( settings ) {
      }
});

$(function(){
	
	$("#submit").click(function(){
		$('.datatable-basic').DataTable().draw();
	});

	$('#birthdayBegin').daterangepicker(
			  { 
				  "singleDatePicker": true,
				  "parentEl":$("#edit_dialog"),
				  showDropdowns: true,
				  startDate: moment().subtract('years', 30),
			    locale:{
			    	format: 'MM-DD',
		            applyLabel: '确认',
		            cancelLabel: '取消',
		            fromLabel: '从',
		            toLabel: '到',
		            customRangeLabel: '选择时间',
		            daysOfWeek:["日","一","二","三","四","五","六"],
		            monthNames: ["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],
		        }
			  }
			);
	 $('#birthdayBegin').val("");
	 
	 $('#birthdayEnd').daterangepicker(
			  { 
				  "singleDatePicker": true,
				  "parentEl":$("#edit_dialog"),
				  showDropdowns: true,
				  startDate: moment().subtract('years', 30),
			    locale:{
			    	format: 'MM-DD',
		            applyLabel: '确认',
		            cancelLabel: '取消',
		            fromLabel: '从',
		            toLabel: '到',
		            customRangeLabel: '选择时间',
		            daysOfWeek:["日","一","二","三","四","五","六"],
		            monthNames: ["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],
		        }
			  }
			);
	 $('#birthdayEnd').val("");
})
